package com.nacos.springboot.snail.controller;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description TODO
 * @Author xueguoping
 * @Date 2021/5/7 15:39
 */
@RestController
public class DiscoveryController {

	@NacosInjected
	private NamingService namingService;

	@GetMapping("/discovery")
	public List<Instance> discovery(@RequestParam String serviceName)throws NacosException {
		System.out.println("discovery");
		return namingService.getAllInstances(serviceName);
	}
}
